package Tables;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.sql.ResultSet;

public class Counsellor extends Table{
    private String name;
    private int age;
    private String telephone;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public Counsellor(Connection connection) {
        super(connection);
    }

    @Override
    public String toString() {
        return "Counsellor{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", telephone='" + telephone + '\'' +
                '}';
    }

    @Override
    public List<String> get() throws SQLException {
        String order = "select * from counsellor";
        PreparedStatement statement = this.connection.prepareStatement(order);
        ResultSet set = statement.executeQuery();
        while(set.next()){
            this.name = set.getString(1);
            this.age = set.getInt(2);
            this.telephone = set.getString(3);
            this.tableList.add(toString());
        }
        return this.tableList;
    }
}
